"""
@Project ：HD_project 
@File    ：demo.py
@IDE     ：PyCharm 
@Author  ：靓仔
@Date    ：2023/12/11 0011 12:56 
"""
import json
import time

import requests

session = requests.session()

headers = {
    'Accept': 'application/json, text/plain, */*',
    'Accept-Encoding': 'gzip, deflate',
    'Accept-Language': 'zh-CN,zh;q=0.9',
    'Autothrowerror': 'true',
    'Connection': 'keep-alive',
    'Content-Length': '80',
    'Content-Type': 'application/json;charset=UTF-8',
    'Ctp-T-Code': '0002200000080659',
    'Host': '10.6.10.110',
    'Origin': 'http://10.6.10.110',
    'Ratio': '945*1512',
    'Referer': 'http://10.6.10.110/',
    'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko)'
                  'Chrome/119.0.0.0 Safari/537.36',
}


def session_login():
    _url = "http://10.6.10.110/jadp-api/auth/session"
    data = {"account": "yanzhi", "password": "DZDR1M81FcALjaYAXpRv/nSA2kYcWRXemwE09Txa1AU="}
    res = json.loads(session.post(url=_url, json=data, headers=headers).text)
    res = res["result"]["data"]["user"]["userId"]
    return res


def get_doc_id():
    url = "http://10.6.10.110/zdgl-api/qc/page"
    data = {"lclx": "2", "flowStatus": None, "dqhj": None, "zbbmName": "", "zbbm": "", "sfybg": "", "pageNo": 1,
            "pageSize": 500, "sfdwqc": 1}
    res = json.loads(session.post(url=url, json=data, headers=headers).text)
    for dic_id in res["result"]["list"]:
        yield dic_id["docId"]


# 承接清单接口
def get_inventory_list():
    nums = 0
    for dic_id in get_doc_id():
        nums += 1
        url = "http://10.6.10.110//zdgl-api/acceptance/oaCallback"
        data = {"id": dic_id}
        res = session.post(url=url, json=data, headers=headers).text
        print(f"{nums}:", res)


if __name__ == '__main__':
    session_login()
    get_inventory_list()
    print("操完完成！关闭当前窗口！")
    time.sleep(15)
